#include "ADC_HAL_GB.h"

void vfnADC_ChannelSelect (uint8 u8channel)
{
    ATD1SC_ATDCH = u8channel;
}

void vfnADC_ConversionMode (uint8 u8mode)
{
    ATD1SC_ATDCO = u8mode;
}

void vfnADC_PinEnable (uint8 u8pin)
{
    if (u8pin > 7)
    {
        return;
    }
    
    ATDPE |= (0x01 << u8pin);
}

void vfnADC_PowerUp (void)
{
    ATDC_ATDPU = 1;
}

void vfnADC_Disable (void)
{
    ATDC_ATDPU = 0;
}

void vfnADC_Resolution (uint8 u8resolution)
{
    ATDC_RES8 = u8resolution;
}

void vfnADC_Signed (uint8 u8sign)
{
    ATDC_SGN = u8sign;
}    

void vfnADC_Justification (uint8 u8justification)
{
    ATDC_DJM = u8justification;
}

void vfnADC_PrescalerSelect (uint8 u8prescaler)
{
    ATDC_PRS = u8prescaler;  
}

uint8 u8ADC_GetResult (void)
{
    return ATDRL;
}

uint8 u8ADC_CheckCCF (void)
{
    return ATD1SC_CCF;
}